package com.kye.express.utils;

import android.content.Context;
import android.os.Build;
import android.util.Log;

import com.kye.express.App;

/**
 * App相关辅助类
 * <p>
 * Desc  获取应用程序的相关设备信息
 * <p>
 * Created by SkyYu on 2018/1/15
 */
public class AppUtil {

    private static final String TAG = "AppUtil";

    private AppUtil() {
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    /**
     * 获取手机系统SDK版本
     *
     * @return 如API 17 则返回 17
     */
    public static int getSDKVersion() {
        return Build.VERSION.SDK_INT;
    }

    /**
     * 获取系统版本号
     *
     * @return String 如4.0, 5.0, 5.1
     */
    public static String getDeviceOSVersion() {
        return Build.VERSION.RELEASE;
    }

    /**
     * @param context 上下文
     * @return model
     */
    public static String getModel(Context context) {
        return Build.MODEL;
    }

    /**
     * @param context context
     * @return MANUFACTURER
     */
    public static String getManufacturer(Context context) {
        return Build.MANUFACTURER;
    }

    /**
     * 获取手机信息
     *
     * @return String
     */
    public String getPhoneInfo() {
        String phoneInfo = "Product: " + Build.PRODUCT;
        phoneInfo += ", CPU_ABI: " + Build.CPU_ABI;
        phoneInfo += ", TAGS: " + Build.TAGS;
        phoneInfo += ", VERSION_CODES.BASE: " + Build.VERSION_CODES.BASE;
        phoneInfo += ", MODEL: " + Build.MODEL;
        phoneInfo += ", SDK: " + Build.VERSION.SDK_INT;
        phoneInfo += ", VERSION.RELEASE: " + Build.VERSION.RELEASE;
        phoneInfo += ", DEVICE: " + Build.DEVICE;
        phoneInfo += ", DISPLAY: " + Build.DISPLAY;
        phoneInfo += ", BRAND: " + Build.BRAND;
        phoneInfo += ", BOARD: " + Build.BOARD;
        phoneInfo += ", FINGERPRINT: " + Build.FINGERPRINT;
        phoneInfo += ", ID: " + Build.ID;
        phoneInfo += ", MANUFACTURER: " + Build.MANUFACTURER;
        phoneInfo += ", USER: " + Build.USER;
        return phoneInfo;
    }

    /**
     * 获取系统状态栏高度
     **/
    public static int getStatusBarHeight(){
        int statusBarHeight = 0;
        // 获取status_bar_height资源的ID
        int resourceId = App.getContext().getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            // 根据资源ID获取响应的尺寸值
            statusBarHeight = App.getContext().getResources().getDimensionPixelSize(resourceId);
        }
        return statusBarHeight;
    }

}
